﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class bbs : System.Web.UI.Page
{
    private DataTable bbsGetData(int pagestart,int pagesize)
    {
        MysqlHelp bbsdata = new MysqlHelp();
        string conn = "select * from bbs where parent=-1 order by top DESC , time DESC limit " + pagestart + "," + pagesize ;
        DataTable recall = bbsdata.GetDatabysql(conn);
        return recall;
    }
    private int recallcount(string id)
    {
        MysqlHelp bbscount = new MysqlHelp();
        string conn = "select * from bbs where parent='" + id + "'";
        DataTable resave = bbscount.GetDatabysql(conn);
        return resave.Rows.Count; 
    }
    protected void Page_Load(object sender, EventArgs e)
    {
      DataTable asbbs = bbsGetData(0,5);
      Response.Write("<table id=\"bbstable\" width=\"60%\"><tr><td id=\"recount\" width=\"10%\">回复</td><td id=\"bbstitle\" width=\"40%\">标题</td><td id=\"bbsauther\" width=\"10%\">作者</td></tr><table>");
      int i;
        for(i=0;i<asbbs.Rows.Count;i++)
        {
            int rec = recallcount(asbbs.Rows[i]["id"].ToString());
            Response.Write(string.Format("<table id=\"bbstable\" width=\"60%\"><tr><td id=\"recount\" width=\"10%\">{0}</td><td id=\"bbstitle\" width=\"40%\"><a href=ForumDisplay.aspx?id={1}>{2}</a></td><td id=\"bbsauther\" width=\"10%\">{3}</td></tr><table>", rec, asbbs.Rows[i]["id"], asbbs.Rows[i]["title"], asbbs.Rows[i]["username"]));
        }
    }
}
